OData - Part 3: Filtering with Static Values

Objective

To filter data based on a single, static criteria through the creation of a simple document which displays a list of discontinued products.

Background Information

Suppose you are required to create a document which lists all of your companies discontinued products so that you can clear out the inventory. AutoTag and the OData Wizard allow you to do just that by creating a filter to find all discontinued products. Here, we won’t show you the actual template creation as you can learn this in several other tutorials such as the ForEach Tag tutorial.

Pre-requisites

Inserting a Tag, ForEach Tag, OData - Part 1: Basic Selection

Starting Template

Start this tutorial with a blank template already connected to an OData datasource. If you don’t know how to do this, or haven’t set up an OData datasource in the past, please check out our Connecting to OData tutorial.

Procedure

1. Insert forEach tag and open OData Wizard

Since this tutorial works in the OData Wizard, we need it open. To open it, simply insert a ForEach tag (after making sure the document has a OData datasource) and click the Wizard button in the AutoTag ribbon, or check out the OData - Part 1: Basic Selection tutorial.

Show Me How!

2. Drag Products as the root resource

The steps to select data are the same here as in Part 1 of the OData Wizard tutorial series. First you need to drag the resource, which is Products in this case.

Show Me How!

3. Drag ProductName and Discontinued properties

Then you need to drag the properties to the select box. We are using ProductName and Discontinued.

Show Me How!

4. Add a group, then add a filter

Now we want to add the filter. In the OData Wizard, to add filters, you have to click the statement click here to add a group first, and then you will see click here to add a filter. Click there now.

Show Me How!

5. Set node of filter to Products.Discontinued

Once you have a filter, you simply need to set the properties so the filter knows what it is filtering. Click onclick here to select a node and select the Discontinued column from the Products table.

Show Me How!

6. Set value of filter to True

Next, click on click here to set the value to set a value to compare Discontinued to. Since we want to see Discontinued products, type True here (with a capital T; OData Wizard is case sensitive in this case). And that’s it. Creating a filter is that easy!

Show Me How!

7. View results in right panel

Of course you probably want to see what kind of output is returned when this filter is applied. You may have already noticed, but you can easily see this in the right side of the window.

Show Me How!

Quiz Yourself!

True/False: Filtering is simply a way of getting rid of the properties I don’t need, so I only get a small number of properties to choose from.
False. Selecting properties from the OData Wizard already removes the unneeded properties from your selection. Filtering filters out entities of data.
True. Filtering can filter out entire properties or just entries.
False. Filtering removes the good stuff from my database so all I’m left with is junk.
True. That’s the point of the OData Wizard.
Can you use drag and drop to create filters?
No. Filters are created by clicking and selecting. Most of the operations in a filter are a simple selection anyway.
No, you have to click first, and then you can drag and drop
Yes. But I’m not sure what to drag so I just click.
Yes. The wizard can do anything! Even collect data from Mars!
Which of the following is not a good use for filters?
Finding data based on criteria that is not stored in the database
Selecting a subset of financial data based on a certain date range
Creating a book list with books only written by a certain author
Like online shopping, I want something that costs less than X, and is made by brand Y

Congratulations!

You have completed this tutorial. We recommend taking a look at the OData - Part 4: Filtering with Variable Values tutorial next!

close
continue